package com.gc.controller.teachclassServlet;


import com.gc.entity.TeachClass;
import com.gc.repository.TeachClassRepository;
import com.gc.repository.impl.TeachClassRepositoryImpl;
import com.gc.service.TeachClassService;
import com.gc.service.impl.TeachClassServiceImpl;
import com.gc.util.result.R;
import com.gc.vo.TeachClassShow;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "teachclassFindById", value = "/teachclassFindById" )
public class teachclassFindById extends HttpServlet {
    TeachClassService teachclassRepository = new TeachClassServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Gson gson = new Gson();
        Long id = Long.valueOf(request.getParameter("id"));
        TeachClassShow teachclass = teachclassRepository.FindById(id);
        System.out.println("测试根据id查找学生");
        System.out.println(teachclass);
        response.getWriter().write(gson.toJson(R.ok().data(teachclass)));
    }
}
